Key Sequence Detection


Posted by wayne201299 on 2023-09-28

為網站添加secret code,輸入後會有小彩蛋

  1. 監聽鍵盤點擊事件
  2. 將點擊的案件推入計算陣列後比對
    const pressed = [];
     const secretcode = 'alan'
     window.addEventListener("keyup", (e) => {
       pressed.push(e.key);
       pressed.splice(-secretcode.length - 1, pressed.length - secretcode.length);
       if (pressed.join('').includes(secretcode)) {
         cornify_add();
       }
     })
    

Konami Code
在前端開發中,Konami Code 通常指的是以下按鍵序列:
上箭頭、上箭頭、下箭頭、下箭頭、左箭頭、右箭頭、左箭頭、右箭頭、B 鍵、A 鍵、Enter(或 Return)鍵


#javascript #html







Related Posts

計數排序(Counting Sort)、基數排序(Radix Sort)

計數排序(Counting Sort)、基數排序(Radix Sort)

滲透測試基本技術 第三章 (004)

滲透測試基本技術 第三章 (004)

數據分析師的末日?GPT-4 的新功能 - code interpreter

數據分析師的末日?GPT-4 的新功能 - code interpreter


Comments